#include "precom.h"
#include "CgShaderInterface.h"

CgShaderInterface::CgShaderInterface()
{
	cg_vertProg = cg_fragProg = NULL;
	for(int i=0; i<MAX_LIGHT_NUMBER; ++i)
		cg_lightPos[i] = NULL;
	m_lightNum = 0;
	cg_modelViewMatrix = NULL;
	cg_modelViewProjMatrix = NULL;
}

CgShaderInterface::~CgShaderInterface()
{
}

void CgShaderInterface::SetLights(const fmath::vector3 *a_lightsTab, size_t a_lightsNum)
{
	for(size_t l=0; l<m_lightNum && l<a_lightsNum; ++l) {
		cgGLSetParameter4f(cg_lightPos[l], a_lightsTab[l].x, a_lightsTab[l].y, a_lightsTab[l].z, 1.0f);
	}
}

void CgShaderInterface::SetWorldViewProjMatrix()
{
	cgGLSetStateMatrixParameter(cg_modelViewProjMatrix,
		CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
	cgGLSetStateMatrixParameter(cg_modelViewMatrix,
		CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);
	/*fmath::matrix44 m;
	m.identity();
	cgGLSetMatrixParameterArrayfr(cg_modelViewMatrix, 0, 0, &(m.col[0][0]));
	*/
}

std::vector<boost::function<void(const fmath::vector3&)>> CgShaderInterface::SignUpForVecInfo()
{
	std::vector<boost::function<void(const fmath::vector3&)>> ret;
	ret.resize(ShaderExternalVecDataNum, NULL);
	return ret;
}

std::vector<boost::function<void(float)>> CgShaderInterface::SignUpForFloatInfo()
{
	std::vector<boost::function<void(float)>> ret;
	ret.resize(ShaderExternalFloatDataNum, NULL);
	return ret;
}